package cl.ncx.cmvrc.persistence.base.entities.personas;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import cl.ncx.cmvrc.persistence.base.entities.grua.Grua;
import cl.ncx.cmvrc.persistence.base.entities.solicitud.OrdenDeTrabajo;

/**
 * Gruero entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "gruero", schema = "base", uniqueConstraints = {@UniqueConstraint(columnNames = "persona")})
@SequenceGenerator(name = "gruero_seque", sequenceName = "base.gruero_gruero_id_seq")
public class Gruero implements java.io.Serializable {

	// Fields

	private Integer grueroId;
	private Persona persona;
	private Grua grua;
	private Set<OrdenDeTrabajo> ordenDeTrabajos = new HashSet<OrdenDeTrabajo>(0);

	// Constructors

	/** default constructor */
	public Gruero() {
	}

	/** minimal constructor */
	public Gruero(Integer grueroId) {
		this.grueroId = grueroId;
		//this.grua_1 = grua_1;
	}

	/** full constructor */
	public Gruero(Integer grueroId, Persona persona,Grua grua,
			Set<OrdenDeTrabajo> ordenDeTrabajos) {
		this.grueroId = grueroId;
		this.persona = persona;
		this.grua = grua;
		this.ordenDeTrabajos = ordenDeTrabajos;
	}

	// Property accessors
	@Id
	@Column(name = "gruero_id", unique = true, nullable = false)
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator = "gruero_seque")
	public Integer getGrueroId() {
		return this.grueroId;
	}

	public void setGrueroId(Integer grueroId) {
		this.grueroId = grueroId;
	}

	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "persona", nullable = false)
	public Persona getPersona() {
		return this.persona;
	}

	public void setPersona(Persona persona) {
		this.persona = persona;
	}
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "grua", nullable = false)
	public Grua getGrua() {
		return this.grua;
	}

	public void setGrua(Grua grua) {
		this.grua = grua;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "gruero")
	public Set<OrdenDeTrabajo> getOrdenDeTrabajos() {
		return this.ordenDeTrabajos;
	}

	public void setOrdenDeTrabajos(Set<OrdenDeTrabajo> ordenDeTrabajos) {
		this.ordenDeTrabajos = ordenDeTrabajos;
	}

}